import { gettoken, settoken, removetoken } from '@/utils/storage.js'//token
import { loginApi } from '@/api/user.js'//用户接口
export default {
  state () {
    return {
      token: gettoken()
    }
  },
  mutations: {

    changeToken (state, token) {
      state.token = token
    },

    removeToken (state) {
      state.token = null
      removetoken()
    }
  },
  actions: {
    async getlogin ({ commit }, data) {
      const res = await loginApi(data)
      console.log(res);
      commit('changeToken', res.data.token)
      settoken(res.data.token)
    }

  },
  getters: {


  },
  namespaced: true
} 